#include "ByteBuffer.hh"
#include "BufferManager.hh"


ByteBuffer   BufferManager::getByteBuffer(){
	ByteBuffer buf(  chunksize);
	bufs.push_back(buf);
	chunknum++;
	return bufs.back();
}

ByteBuffer   BufferManager::mergeAll(){
	size_t s=chunksize*chunknum;
	ByteBuffer buf(  s);
	size_t offset=0;
	for(int i=0;i<chunknum;i++){
		offset+=chunksize;
		memcpy(buf.getptr()+offset ,bufs[i].getptr() ,chunksize   );
	}
	
	return buf;
}


BufferManager::~BufferManager(){


}
